package com.atguigu.service.impl;


import com.atguigu.base.BaseMapper;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.entity.Permission;
import com.atguigu.helper.PermissionHelper;
import com.atguigu.mapper.PermissionMapper;
import com.atguigu.service.PermissionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PermissionServiceImpl extends BaseServiceImpl<Permission> implements PermissionService{

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public BaseMapper<Permission> getBaseMapper() {
        return permissionMapper;
    }


    @Override
    public List<Permission> findPermissionListByAdminId(Long adminId) {
        //根据用户id查询权限集合
        List<Permission> permissionList = permissionMapper.findPermissionListByAdminId(adminId);
        permissionList = PermissionHelper.build(permissionList);
        return permissionList;
    }

    @Override
    public List<String> findPermissionCodeListByAdminId(Long adminId) {
        return permissionMapper.findPermissionCodeListByAdminId(adminId);
    }
}

